package com.dianzhang.disruptor.tools;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import org.springframework.stereotype.Component;

/**
 * @author xingyulai
 * @date 2024/2/21 4:30 PM
 * @description
 **/
@Component
public class DisruptorMessageHandler implements EventHandler<DisruptorMessage> , WorkHandler<DisruptorMessage> {

    private int i=0;
    @Override
    public void onEvent(DisruptorMessage disruptorMessage, long l, boolean b) throws Exception {
        i++;
        System.out.println("EventHandler--->线程名" + Thread.currentThread().getName() + "｜消息内容=" + disruptorMessage.getContent()+"|访问次数="+i);

    }

    @Override
    public void onEvent(DisruptorMessage disruptorMessage) throws Exception {

        i++;
        System.out.println("WorkHandler--->线程名" + Thread.currentThread().getName() + "｜消息内容=" + disruptorMessage.getContent()+"|访问次数="+i);


    }
}
